package com.example.jdbctemplateplusexample.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 自定义全局异常处理类
 */
@ControllerAdvice
public class MyControllerAdvice {
    /**
     * 处理其他异常
     * @param e
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public  String exceptionHandler(Exception e) {
        return  e.getCause()==null? e.getMessage():e.getCause().getMessage();
    }
}
